home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / owlbwcc.zip / BWCIMMED.CPP < prev    next >
C/C++ Source or Header  |  1992-02-02  |  4KB  |  100 lines

  1. /**********************************************************************/
  2. /*                  BWCIMMED.cpp by Bob Bourbonnais                   */
  3. /*              released to the public domain 2/02/92                 */
  4. /*          This program shows how to switch to different             */
  5. /*           routines based on the button pressed using               */
  6. /*           Dynamic Dispatched Virtual Tables, DDVT                  */
  7. /*          It also shows how to use BC_GETCHECK to show              */
  8. /*                the ON/OFF status of check boxes                    */
  9. /**********************************************************************/
  10. #include <owl.h>
  11. #include <dialog.h>
  12. #include "bwcc.h"                        // needed for BWCC
  13. #include "BWCIMMED.H"                    // equates for checkboxes
  14.  
  15. class TMyDialog : public TDialog
  16.   {
  17.   public:
  18.     TMyDialog(LPSTR lpDialogName)          // constructor calls
  19.       : TDialog(NULL,lpDialogName)         // base class constructor
  20.       {
  21.       BWCCGetVersion();    // activate Borland Windows Custom Controls
  22.       }
  23.     virtual void HandleRadar12(RTMessage Msg)  // these DDVT toggles
  24.       = [ID_FIRST + IDB_RADAR12];              // activate immediately
  25.     virtual void HandleConfabulator12(RTMessage Msg) // like regular
  26.       = [ID_FIRST + IDB_CONFABULATOR12];             // buttons
  27.  
  28.     virtual void DefChildProc(RTMessage Msg); // default button handler
  29.   };
  30.  
  31. void TMyDialog::HandleRadar12(RTMessage)
  32.   {
  33.   if (SendDlgItemMsg(IDB_RADAR12,BM_GETCHECK,0,0))  // find out the ON/OFF
  34.     {                                               // status of the checkbox
  35.     MessageBeep(0);                                 // if we turned it on
  36.     BWCCMessageBox(HWindow,"Radar Unit 12 Activated", // beep and display
  37.                "ACTIVATION!",MB_OK);      // message box
  38.     }
  39.   else                                              // if we turned it off
  40.     {
  41.     MessageBeep(0);                                 // beep and display a
  42.     BWCCMessageBox(HWindow,"Radar Unit 12 OFF",     // different message
  43.                "SHUTDOWN!",MB_OK);
  44.     }
  45.   }
  46.  
  47. void TMyDialog::HandleConfabulator12(RTMessage)     // Same for second
  48.   {                                                 // Item
  49.   if (SendDlgItemMsg(IDB_CONFABULATOR12,BM_GETCHECK,0,0))
  50.     {
  51.     MessageBeep(0);
  52.     BWCCMessageBox(HWindow,"Confabulator on Unit 12 Activated",
  53.                "ACTIVATION!",MB_OK);
  54.     }
  55.   else
  56.     {
  57.     MessageBeep(0);
  58.     BWCCMessageBox(HWindow,"Confabulator on Unit 12 OFF",
  59.                "SHUTDOWN!",MB_OK);
  60.     }
  61.   }
  62.  
  63. void TMyDialog::DefChildProc(RTMessage Msg)   // default button handler
  64.   {
  65.   MessageBeep(0);                             // make sound and display
  66.   BWCCMessageBox(HWindow,"Not Implemented",   // a BWCC message box
  67.          "Feature",MB_OK);
  68.   TDialog::DefChildProc(Msg);                 // pass messages along
  69.   }                                           // to base class handler
  70.  
  71. class TDialog1App : public TApplication  // Application Class to contain
  72.   {                                      // the application
  73.   public:
  74.     TDialog1App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  75.         HANDLE hPrevInstance,            // base class constructor
  76.         LPSTR lpCmdLine, int nCmdShow)
  77.         :TApplication(lpName, hInstance,
  78.                   hPrevInstance,
  79.                   lpCmdLine, nCmdShow) {};
  80.  
  81.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  82.   };
  83.  
  84. void TDialog1App::InitMainWindow() // to initialize a dialog box
  85.   {                                // as the main window
  86.   MainWindow = new TMyDialog("MAINWINDOWDIALOG");
  87.   }
  88.  
  89. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  90.            HANDLE hPrevInstance,          // windows to this program
  91.            LPSTR lpCmdLine , int nCmdShow)
  92.   {
  93.   TDialog1App Dialog1("Dialog Tester",hInstance,  // create instance of
  94.                hPrevInstance,             // the dialog application
  95.                lpCmdLine,nCmdShow);
  96.   Dialog1.Run();                                  // run it
  97.   return (Dialog1.Status);                        // exit
  98.   }
  99. /**********************************************************************/
  100.